package cn.nuaa.cms.common;

import cn.nuaa.cms.controller.IndexController;
import cn.nuaa.cms.model.CollectInfo;
import cn.nuaa.cms.model.Department;
import cn.nuaa.cms.model.Info;
import cn.nuaa.cms.model.LoginInfo;
import cn.nuaa.cms.model.LookInfo;
import cn.nuaa.cms.model.Organize;
import cn.nuaa.cms.model.Relation;
import cn.nuaa.cms.model.User;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.ehcache.EhCachePlugin;
import com.jfinal.render.ViewType;

public class NuaaCmsConfig extends JFinalConfig {
	public void configConstant(Constants me) {
		PropKit.use("config.properties");
		me.setViewType(ViewType.JSP);
		me.setDevMode(true);
	}

	public void configRoute(Routes me) {
		me.add("/", IndexController.class);
	}

	public void configPlugin(Plugins me) {
		DruidPlugin druidPlugin = new DruidPlugin(PropKit.get("jdbcUrl"),
				PropKit.get("username"), PropKit.get("password"));
		me.add(druidPlugin);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
		// 设置是否打印sql
		arp.setShowSql(true);
		arp.addMapping("user", User.class);
		arp.addMapping("info", Info.class);
		arp.addMapping("relation", Relation.class);
		arp.addMapping("department", Department.class);
		arp.addMapping("login_info", LoginInfo.class);
		arp.addMapping("organize", Organize.class);
		arp.addMapping("collect_info", CollectInfo.class);
		arp.addMapping("look_info", LookInfo.class);
		me.add(arp);
		me.add(new EhCachePlugin());
	}

	public void configInterceptor(Interceptors me) {
	}

	public void configHandler(Handlers me) {
	}



}
